#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/12/13 17:12|17:12
# @Author  : yangdingyi
# @File    : 有效的字母异位词
# @Software: PyCharm


class Solution:
    def isAnagram(self, s: str, t: str) -> bool:
        m = {}
        for c in s:
            if m.get(c, None):
                m[c] += 1
            else:
                m[c] = 1
        mm = {}
        for c in t:
            if mm.get(c, None):
                mm[c] += 1
            else:
                mm[c] = 1
        ans = m == mm

        from collections import Counter
        c1 = Counter(s)
        c2 = Counter(t)
        ans = c1 == c2
        return ans


solve = Solution()

s = "anagram"
t = "nagaram"

solve.isAnagram(s, t)

